package com.ext.aic.apis;

import com.ext.aic.beans.response.ExceptionResponse;
import com.hjq.http.exception.ResponseException;

import java.io.Serializable;

import okhttp3.Response;

public class BaseRequest<Param, Extra> implements Serializable {

    protected void responseExceptionHandler(Throwable throwable, Param param, Extra extra) {
        if (throwable instanceof ResponseException) {
            ResponseException exception = (ResponseException) throwable;
            Response exceptionResponse = exception.getResponse();
            ExceptionResponse response = new ExceptionResponse();
            response.setCode(exceptionResponse.code());
            response.setMessage(exceptionResponse.message());
            onFail(response, param,extra);
        }
    }

    protected void onFail(ExceptionResponse response, Param param, Extra extra) {

    }
}
